home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10831 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.0 KB  |  131 lines

  1. Path: tank.news.pipex.net!pipex!warwick!not-for-mail
  2. From: esuqf@csv.warwick.ac.uk (Praveen)
  3. Newsgroups: comp.lang.c++
  4. Subject: Class of incomplete type - HELP
  5. Date: 10 Mar 1996 21:15:21 -0000
  6. Organization: University of Warwick, Coventry, UK
  7. Message-ID: <4hvgp9$8jr@crocus.csv.warwick.ac.uk>
  8. NNTP-Posting-Host: crocus-fddi.csv.warwick.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=US-ASCII
  11. Content-Transfer-Encoding: 7bit
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14.  
  15. Hi,
  16.  
  17. I've got a problem for an assignment which consists of helping a user 
  18. solve a single substitution cryptogram. I've spent ages trying to correct a 
  19. compilation error. Could someone please help? Here's the situation:
  20.  
  21.  
  22. I've got three classes:
  23.  
  24.  
  25. class List {
  26.  
  27. // Used to store the cryptogram in a linked list.
  28. // Works OK
  29.  
  30. ..........
  31.  
  32. }
  33.  
  34.  
  35. class alphabet {
  36.  
  37. // Uses two arrays - one stores the ciphertext letters 'a' to 'z'
  38. // The other stores their assumed plaintext values, or a '*' if no value 
  39. // has yet been deciphered by the program.
  40.  
  41. public:
  42.  
  43. char plain (char cipherin) {
  44.  
  45. // Returns the assumed plaintext value of a given cipher letter by 
  46. // looking up in the arrays
  47.  
  48. }
  49.  
  50. ..........
  51.  
  52. }
  53.  
  54.  
  55. class Blackboard {
  56.  
  57. // Used to store two linked lists with operations defined to modify them
  58.  
  59.  
  60. public:
  61.  
  62. ..........
  63.  
  64. Boolean isSolved() {
  65.  
  66. // Returns True if cryptogram is solved, False otherwise.
  67.  
  68. .........
  69.     char cipherletter = current->letter // Character node of linked list
  70.     if ( plain(cipherletter) == '*' )
  71.             return False;
  72.  
  73. .........
  74.  
  75. }
  76.  
  77. }
  78.  
  79.  
  80. PROBLEMS
  81. --------
  82.  
  83. 1. I compile using: g++ list.C alphabet.C blackboard.C
  84.  
  85.    Error message:
  86.    blackboard.C: In method `enum Boolean Blackboard::isSolved()':
  87.    blackboard.C:70: warning: implicit declaration of function `int plain(...)'
  88.                                                                ^^^
  89.    Strange Thing: The return type of function plain should be char. Or 
  90.                   am I missing something??
  91.  
  92.  
  93. 2. I tried to inherit the alphabet class in the Blackboard class, 
  94.    thinking that the code would work if char plain(..) becomes a 
  95.    member function of Blackboard, I get the following:
  96.  
  97.    class Blackboard: public alphabet {
  98.    ..............
  99.    }
  100.  
  101.    blackboard.H:4: base class `alphabet' has incomplete type
  102.  
  103.    What does incomplete type mean?
  104.    Has it got anything to do with constructors and destructors, which 
  105.    I have not included in my classes ?
  106.  
  107.  
  108. 3. Next, I thought that declaring an instance of alphabet and calling 
  109.    plain as follows would work:
  110.  
  111.    alphabet v;
  112.    if ( v.plain(cipherletter) == '*' ) {
  113.        ...........
  114.    }
  115.  
  116.    Error messages:
  117. blackboard.C:8: aggregate `class alphabet v' has incomplete type and cannot 
  118. be initialized
  119. blackboard.C: In method `enum Boolean Blackboard::isSolved()':
  120. blackboard.C:70: `cipherletter' undeclared (first use this function)
  121. blackboard.C:70: (Each undeclared identifier is reported only once
  122. blackboard.C:70: for each function it appears in.)
  123.  
  124.  
  125. I just can't understand what's going on. Any help would be appreciated.
  126. Thanks.
  127.  
  128.  
  129. --
  130. Praveen.
  131.